<template>
  <div class="operationLog">
    <h3>操作日志</h3>
    <div class="search">
      <div class="cond1 cond">
        <el-input placeholder="请输入管理员id" v-model="search1">
          <template slot="prepend">管理员id</template>
        </el-input>
      </div>
      <div class="cond1 cond">
        <el-input placeholder="请输入用户名" v-model="search2">
          <template slot="prepend">管理员用户名</template>
        </el-input>
      </div>
      <div class="cond1 cond">
        <el-input placeholder="请输入昵称" v-model="search3">
          <template slot="prepend">管理员昵称</template>
        </el-input>
      </div>
      <div class="cond1 cond">
        <el-input placeholder="请输入主题" v-model="search4">
          <template slot="prepend">主题</template>
        </el-input>
      </div>
      <div class="cond1 cond">
        <el-input placeholder="请输入模块" v-model="search5">
          <template slot="prepend">模块</template>
        </el-input>
      </div>
      <div class="cond1 cond">
        <el-input placeholder="请输入ip" v-model="search6">
          <template slot="prepend">ip地址</template>
        </el-input>
      </div>
      <div>
        <el-button type="primary" icon="el-icon-search" @click="searchMethod">搜索</el-button>
      </div>
    </div>
    <div class="list">
      <el-table
        border
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
      >
        <el-table-column type="index" width="50" header-align="center" align="center" label="序号"></el-table-column>
        <el-table-column header-align="center" align="center" prop="id" label="id" width="80"></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="manager_id"
          label="管理员id"
          width="170"
        ></el-table-column>
        <el-table-column header-align="center" align="center" prop="username" label="管理员用户名"></el-table-column>
        <el-table-column header-align="center" align="center" prop="nick" label="管理员昵称"></el-table-column>
        <el-table-column header-align="center" align="center" prop="subject" label="主题"></el-table-column>
        <el-table-column header-align="center" align="center" prop="module" label="模块" width="130"></el-table-column>
        <el-table-column header-align="center" align="center" prop="action" label="操作名"></el-table-column>
        <el-table-column header-align="center" align="center" prop="svalue" label="关联值" width="80"></el-table-column>
        <el-table-column header-align="center" align="center" prop="ip" label="IP" width="110"></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="created_at"
          label="操作时间"
          width="170"
        ></el-table-column>
      </el-table>
    </div>
    <div class="page">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage1"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="totalSize"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  name: "operationLog",
  data() {
    return {
      search1: "",
      search2: "",
      search3: "",
      search4: "",
      search5: "",
      search6: "",
      tableData: [],
      currentPage1: 1,
      pageSize: 10,
      totalSize: 0,
      listData: {}
    };
  },
  mounted() {
    this.getDataList();
  },
  methods: {
    // 分页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage1 = val;
      this.getDataList();
    },
    //获取初始化数据列表
    async getDataList() {
      let parames = {
        handshake: "",
        data: {
          manager_id: this.search1,
          username: this.search2,
          nick: this.search3,
          subject: this.search4,
          module: this.search5,
          ip: this.search6,
          page: this.currentPage1,
          page_size: this.pageSize
        }
      };
      let res = await this.$axios.post(
        this.$api.systemLogLists,
        JSON.stringify(parames)
      );
      if (res.code == 200) {
        this.listData = res.data;
        this.totalSize = this.listData.total;
        this.tableData = this.listData.data;
      } else {
        this.$message({
          message: res.message,
          type: "warning"
        });
      }
    },
    //搜索
    searchMethod() {
      this.getDataList();
    }
  }
};
</script>
<style scoped>
h3 {
  padding: 0.2rem;
  color: #3c763d;
}
.search {
  display: flex;
  margin-top: 0.2rem;
  padding-left: 0.2rem;
  width: 100%;
  flex-wrap: wrap;
}
.el-input {
  width: 2.5rem;
}
label {
  width: 0.83rem;
  height: 0.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f7fa;
  color: #909399;
  border: 1px solid #dcdfe6;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
}
.cond {
  display: flex;
  margin-right: 0.4rem;
  margin-bottom: 0.1rem;
}
.search .el-select >>> .el-input__inner {
  border-left: none;
  border-top-left-radius: 0px;
  border-bottom-left-radius: 0px;
}
.search .el-select {
  width: 1.67rem;
}
.opration {
  margin-top: 0.2rem;
  padding-left: 0.2rem;
}
.page {
  margin-top: 0.2rem;
  display: flex;
  justify-content: center;
}
.list {
  margin-top: 0.2rem;
  padding: 0 0.1rem;
  font-size: 0.12rem;
}
.dialogBtn {
  display: flex;
  justify-content: center;
  margin-top: 0.3rem;
}
.row {
  margin-bottom: 0.1rem;
  display: flex;
  align-items: center;
}
.row span {
  width: 1rem;
  display: block;
}
.detail .title {
  margin-bottom: 0.1rem;
  color: #05a4bf;
}
.detail .detailBox {
  display: flex;
  flex-wrap: wrap;
}
.detail .detailItem {
  width: 100%;
  margin-bottom: 0.1rem;
}
</style>